# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=backports.functools_lru_cache
pkgbase=mingw-w64-python2-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-python2-${_realname}"
pkgver=1.5
pkgrel=2
pkgdesc="Backport of functools.lru_cache from Python 3.3 as published at ActiveState (mingw-w64)"
arch=('any')
url='https://github.com/jaraco/backports.functools_lru_cache'
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python2-backports")
makedepends=("${MINGW_PACKAGE_PREFIX}-python2"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools-scm")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python2-pytest-runner")
optdepends=("${MINGW_PACKAGE_PREFIX}-python2-ipaddress: for IPAddress ServerAltnames support")
options=('staticlibs' 'strip' '!debug')
source=("https://pypi.io/packages/source/b/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('9d98697f088eb1b0fa451391f91afb5e3ebde16bbdb272819fd091151fda4f1a')

prepare() {
  cd "${srcdir}"

}

build() {
  rm -rf python2-build-${CARCH}
  cp -r "${_realname}-${pkgver}" "python2-build-${CARCH}"
  cd python2-build-${CARCH}

  ${MINGW_PREFIX}/bin/python2 setup.py build
}

check() {
  cd python2-build-${CARCH}

  ${MINGW_PREFIX}/bin/python2 setup.py pytest
}

package() {
  cd "${srcdir}/python2-build-${CARCH}"

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  # This looks odd but the backports namespace module was imported earlier
  rm "$pkgdir${MINGW_PREFIX}/lib/python2.7/site-packages/backports/"__init__.py*
}

